Confirm you have an active GitHub Copilot subscription.
Open RStudio.
Go to Tools > Global Options > Copilot tab.
Tick “Enable GitHub Copilot”
Click Install to download Copilot Agent components if prompted.
Click Sign In.
In the dialog, copy the Verification Code shown.
Paste the code on GitHub verification page to authenticate your RStudio IDE session.
Restart RStudio to finalize setup.
Using GitHub Copilot: Workflow & Features
Copilot offers ghost text autocomplete suggestions as you type.
Suggestions are AI-generated, not simple static completions.
Hit Tab to accept; Arrow keys to cycle suggestions.
Use Copilot to:
Write functions based on comments.
Generate boilerplate code.
Get context-aware suggestions.
Example usage in R:
# Calculate the mean of a vectormean_vec <-function(x) {# Copilot will suggest the function body here}
How to video:
How to Ask Questions with GitHub Copilot
Use a comment starting with # q: plus a question mark ? at the end.
Copilot interprets this as a request for an answer and returns a comment response starting with # a:
Example:
# q: How to summarize data by group in dplyr?# a: library(dplyr)summary <- data %>%group_by(group_var) %>%summarize(mean_value =mean(target_var, na.rm =TRUE))
Getting Started with Other LLMs in RStudio
Beyond Copilot, you can use Google Cloud-based LLMs (e.g., Gemini).